package com.superatom.concurrent.basic.daemon;

public class SimpleDaemons implements Runnable{
    public void run() {
        while (true){
            try {
                Thread.sleep(100);
                System.out.println(Thread.currentThread() + " " + this);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10; i++){
            Thread daemon = new Thread(new SimpleDaemons());
            // 设置为后台线程
            daemon.setDaemon(true);
            daemon.start();
        }

        System.out.println("All daemons started");
        Thread.sleep(175);
    }
}
